layui.use(['layer','form', 'layedit'], function(){
    var form = layui.form
    ,layer = layui.layer

    //自定义验证规则
    form.verify({
      title: function(value){
        if(value.length < 5){
          return '标题至少得5个字符啊';
        }
      }
      ,pass: [/(.+){6,12}$/, '密码必须6到12位']
      ,content: function(value){
        layedit.sync(editIndex);
      }
    });

    
    //监听提交
    form.on('submit(login)', function(data){
      myAjax(url+'/admin/login/login',data.field,'post','json',function(res){
        if(res.status===0){
          layer.alert(res.msg,function (){
            location.href=url+'/admin';
          })
        }
      },function (res, textStatus, errorThrown){
        layer.msg(res.responseText,function (){

        })
      })
      return false;
    });
});